import sys
import os
from PyQt5.QtWidgets import QApplication, QMessageBox
from gui.main_window import GrubEditorWindow
from core.parser import GrubConfigParser

def main():
    if os.name == 'nt':
        reply = QMessageBox.information(
            None, "仅 Linux 可用",
            "此工具仅用于 Linux 系统下的 GRUB2 配置。\n"
            "Windows 上仅支持界面展示和导出配置。",
            QMessageBox.Ok | QMessageBox.Cancel
        )
        if reply == QMessageBox.Cancel:
            return

    app = QApplication(sys.argv)
    parser = GrubConfigParser(simulate_mode=(os.name == 'nt'))
    window = GrubEditorWindow(parser, offline_mode=(os.name == 'nt'))
    window.setWindowTitle("GRUB2图形化编辑器 - 模拟模式" if os.name == 'nt' else "GRUB2图形化编辑器")
    window.show()
    sys.exit(app.exec_())

if __name__ == "__main__":
    main()